﻿using Encodings;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Text;

namespace Encodings.Test
{
    [TestClass()]
    public class EncodingsTest
    {
        [TestMethod()]
        [DeploymentItem("Encodings.exe")]
        public void ChangeTextEncodingTest()
        {
            string text = "get this";
            string expected = "get this";
            byte[] originalByteString = Encoding.GetEncoding("windows-1251").GetBytes(text);
            byte[] convertedByteString = Encoding.Convert(Encoding.GetEncoding("windows-1251"),
            Encoding.UTF8, originalByteString);
            expected = Encoding.UTF8.GetString(convertedByteString);
            string actual;
            actual = Encodings_Accessor.ChangeTextEncoding(text);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        [DeploymentItem("Encodings.exe")]
        public void MainTest()
        {
            Encodings_Accessor.inputFile = "../../../Encodings/input.txt";
            Encodings_Accessor.inputFile = "../../../Encodings/output.txt";
            Encodings_Accessor.Main();
        }
    }
}
